<!DOCTYPE html>
<html class="x-admin-sm">
  
  <head>
    {include file="public/head"}
    <style>
      #back{
        position: absolute;
        top: 3px;
        right: 70px;
        z-index: 100;
      }
    </style>
  </head>
  
  <body>
    {include file="public/breadcrumb"}
    <!-- 返回上一级 -->
    {if $pid>0}
    <a id="back" href="/admin.php/Menu/index?m_id={$menu_s.mid}&pid={$backid}" class="layui-btn">返回</a>
    {/if}
    <div class="x-body">
      <form class="layui-form">
        <input type="hidden" name="pid" value="{$pid}">
        <table class="layui-table layui-form">
          <thead>
            <tr>
              <th>ID</th>
              <th>排序</th>
              <th>菜单名称</th>
              <th>控制器</th>
              <th>方法</th>
              <th>图标</th>
              <th>是否隐藏</th>
              <th>是否禁用</th>
              <th>操作</th>
            </tr>
          </thead>
          <tbody>
            {volist name="data.lists" id="vo"}
            <tr>
              <td width="40">{$vo.mid}</td>
              <td><input type="text" class="layui-input" name="ords[{$vo.mid}]" value="{$vo.ord}"></td>
              <td><input type="text" class="layui-input" name="titles[{$vo.mid}]" value="{$vo.title}"></td>
              <td><input type="text" class="layui-input" name="controllers[{$vo.mid}]" value="{$vo.controller}"></td>
              <td><input type="text" class="layui-input" name="methods[{$vo.mid}]" value="{$vo.method}"></td>
              <td><input type="text" class="layui-input" name="icons[{$vo.mid}]" value="{$vo.icon}"></td>
              <td><input type="checkbox" lay-skin="primary" name="ishiddens[{$vo.mid}]" title="隐藏" {$vo.ishidden?'checked':''} value=1></td>
              <td><input type="checkbox" lay-skin="primary" name="status[{$vo.mid}]" title="禁用" {$vo.status?'checked':''} value=1></td>
              <td><button class="layui-btn layui-btn-xs" onclick="child({$vo.mid});return false;">子菜单</button></td>
            </tr>
            {/volist}
            <tr>
              <td></td>
              <td><input type="text" class="layui-input" name="ords[0]"></td>
              <td><input type="text" class="layui-input" name="titles[0]"></td>
              <td><input type="text" class="layui-input" name="controllers[0]"></td>
              <td><input type="text" class="layui-input" name="methods[0]"></td>
              <td><input type="text" class="layui-input" name="icons[0]"></td>
              <td><input type="checkbox" lay-skin="primary" name="ishiddens[0]" title="隐藏" value=1></td>
              <td><input type="checkbox" lay-skin="primary" name="status[0]" title="禁用" value=1></td>
              <td></td>
            </tr>
          </tbody>
        </table>
      </form>
      <button class="layui-btn" onclick="save()">保存</button>
    </div>
    <script>
      layui.use(['layer','form'],function(){
        $ = layui.jquery;
        layer = layui.layer;
        form = layui.form;
      });

      // 子菜单
      function child(pid){
        window.location.href="/admin.php/Menu/index?m_id={$menu_s.mid}&pid="+pid;
      }

      // 保存
      function save(){
        $.post('/admin.php/menu/save',$('form').serialize(),function(res){
          if(res.code>0){
            layer.alert(res.msg,{'icon':2});
          }else{
            layer.msg(res.msg,{'icon':1});
            setTimeout(function(){window.location.reload();},1000);
          }
        },'json');
      }
    </script>
  </body>

</html>